﻿using Contract.Domain;
using Contract.Infrastructure.Repository;
using Contract.Read_WebApi.Application.Commands;
using MediatR;

namespace Contract.Read_WebApi.Application.CommandHandler
{
    public class InfoContractCommandHandler : IRequestHandler<InfoContractCommands, Domain.Contract>
    {
        private readonly IRepository<Domain.Contract> repository;

        public InfoContractCommandHandler(IRepository<Domain.Contract> repository)
        {
            this.repository = repository;
        }

        public async Task<Domain.Contract> Handle(InfoContractCommands request, CancellationToken cancellationToken)
        {
            var info = await repository.GetAsync(x => x.ContractNumber == request.ContractNumber);
            return info;
        }
    }
}
